<script type="text/javascript">
              
    function putMarker(number, id, title, desc, address, lat, lng, primaryPhoto) {
        try {
            if ( (lat != undefined && lat.replace(/^\s+|\s+$/g, '') != '') &&
                 (lng != undefined && lng.replace(/^\s+|\s+$/g, '') != '')) {

                var contentString = '<div class="MarkerPopUp" style="text-align:left; min-width:50px; min-height:80px; overflow:hidden; ">' +
                    '<div class="">' +
                    '<table border="0" width="50px;">' +                    
                    '<tr>' +
                    '<td style="padding:5px;"><a href="<c:out value="${model.props.appPath}"/>/listing/'+title+'/'+id+'"><img src="<c:out value="${model.props.rootPath}"/>/uploads/img/002-'+primaryPhoto+'" /></a></td>' +
                    '</tr>' +
                    '<tr>' +
                    '<td style="padding:2px; text-align:left;"><a href="<c:out value="${model.props.appPath}"/>/listing/'+title+'/'+id+'"><span style="font-weight: bold; font-size:14px; font-family: Century Gothic, Calibri;">' + title + '</span></a></td>' +
                    '</tr>' +
                    '<tr>' +
                    '<td style="padding:2px; text-align:left;"><span style="font-weight: normal; font-size:12px; font-family: Century Gothic, Calibri;">' + address + '</span></td>' +
                    '</tr>' +
                    '</table>' +
                    '</div>' +
                    '</div>';

                    myLatlng = new google.maps.LatLng(lat, lng);
                    var marker = new google.maps.Marker({ position: myLatlng, map: map, title: 'Hello World!' });
                    markers.push(marker);

                    var infoWindow = new google.maps.InfoWindow({
                        content: contentString
                    });

                    listingMarkers.push(marker);
                    google.maps.event.addListener(marker, 'click', function() {
                        infoWindow.open(map, marker);
                    });
                
                    map.setCenter(myLatlng);
            }
        } 
        catch (e) {
            alert("to?" + e);
        }
    }
        
    function codeListings() {  
        
        var id = '<c:out value="${model.listing.id}"/> ';
        var title = '<c:out value="${model.listing.title}"/> ';
        var address = '<c:out value="${model.listing.address}"/> ';
        var lat = '<c:out value="${model.listing.lat}"/> ';
        var lng = '<c:out value="${model.listing.lng}"/> ';
        var primaryPhoto = '<c:out value="${model.listing.primaryPhoto.filename}"/> ';
        
        putMarker('<c:out value="${listingCtr}"/>', id, title, "", address, lat, lng, primaryPhoto); 
    }
    
</script>